using UnityEngine;
using System.Collections;

public class BuildUI_Price : MonoBehaviour
{
	public int iPriceToPay;
	public int iPrice;

	// Use this for initialization
	void Start ()
	{
        transform.position = Camera.main.ScreenToViewportPoint(Input.mousePosition);
		transform.localScale = new Vector3 (10, 10, 0);
	}
	
	// Update is called once per frame
	void Update ()
	{
        transform.position = Camera.main.ScreenToViewportPoint(Input.mousePosition);
		CalculatePrice ();
		GetComponent<GUIText>().text = string.Format("$ {0}", iPriceToPay);
	}

	public void CalculatePrice(){
        int iPayCount = 0;
        for (int i = 0; i < GameObject.Find("BuildUI").transform.childCount; ++i)
        {
            if (!GameObject.Find("BuildUI").transform.GetChild(i).GetComponent<BuildUI>().m_bUITile)
                iPayCount += 1;
        }

        iPriceToPay = iPayCount * iPrice;
	}
}

